<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 
<META HTTP-EQUIV="expires" CONTENT="0">
<title>jnocnews test</title>
<link type="text/css" href="css/main.css" rel="stylesheet" />
<!--<link type="text/css" rel="stylesheet" href="css/style.css" />-->
<link type="text/css" href="css/main.css" rel="stylesheet" />
<link type="text/css" href="js/jquery/themes/base/jquery.ui.all.css" rel="stylesheet" />

	<script src="js/jquery/jquery-1.6.1.min.js"></script>
	<script type="text/javascript" src="js/pushlet/js-pushlet-client.js"></script>
 	<script type="text/javascript" src="js/pushlet/api.js"></script>
 	<script src="js/operamasks/ui/jquery.ui.core.js"></script>
    <script src="js/operamasks/ui/jquery.ui.widget.js"></script>
    <script src="js/operamasks/ui/om-messagetip.js"></script>

    <link rel="stylesheet" href="js/operamasks/themes/default/om-all.css">

<script type="text/javascript" src="js/jquery/ui/jquery-ui-1.8.custom.js"></script>
<script type="text/javascript" src="js/formjson.js"></script>
<script type="text/javascript" src="js/jquery/json2.js"></script>
<script type="text/javascript">
		$(function(){
			// Accordion
			$("#accordion").accordion({ header: "h3" });

			$('#loginDialog').dialog({
				autoOpen: false,
				height: 300,
				width: 350,
				modal: true,
				closeOnEscape: false,
				buttons: {					
					'注册': function() {
						regFrame();
					},
					'登录': function() {
						login();
					}
				}
			});
			$('#loginDialog').bind( "dialogbeforeclose", function(event, ui) {
				return false;
			});
			$('#regDialog').dialog({
				autoOpen: false,
				height: 300,
				width: 350,
				modal: true,
				closeOnEscape: false,
				buttons: {				
                    '取消': function() {
						loginFrame();
					},				
					'注册': function() {
						reg();
					}
				}
			});
			$('#regDialog').bind( "dialogbeforeclose", function(event, ui) {
				return false;
			});
		});
		
		$(function(){
			jQuery.ajax( {
				type : 'POST',
				contentType : 'application/json',
				url : 'userInfo/getLoginUser.do',
				dataType : 'json',
				success : function(resp) {
					if (!resp.successed) {
						$('#loginDialog').dialog('open');
					}
				},
				error : ajaxFailed
			});
		})
	
		function regFrame(){
		    $('#loginDialog').unbind( "dialogbeforeclose" );
			$('#loginDialog').bind( "dialogbeforeclose", function(event, ui) {
				return true;
			});
		    $('#loginDialog').dialog('close');		    
			$('#regDialog').dialog('open');
		}
		
		function loginFrame(){
		    $('#regDialog').unbind( "dialogbeforeclose" );
			$('#regDialog').bind( "dialogbeforeclose", function(event, ui) {
				return true;
			});
		    $('#regDialog').dialog('close');		    
			$('#loginDialog').dialog('open');
		}
		
		function reg(){
		var name=$("#regForm #name").val();
		  var loginInfo = $('#regForm').serializeObject();
			var jsonLoginInfo = JSON.stringify(loginInfo);
			jQuery.ajax( {
				type : 'POST',
				contentType : 'application/json',
				url : 'userInfo/reg.do',
				data : jsonLoginInfo,
				dataType : 'json',
				success : function(resp) {
					if (resp.successed) {
						$('#regDialog').unbind( "dialogbeforeclose" );
						$('#regDialog').bind( "dialogbeforeclose", function(event, ui) {
							return true;
						});
						alert("注册成功！");
						$('#regDialog').dialog('close');
					} else {
						alert(resp.errors[0].message);
					}
				},
				error : ajaxFailed
			});
		}
		
		
		function login() {
			var loginInfo = $('#loginForm').serializeObject();
			var jsonLoginInfo = JSON.stringify(loginInfo);
			jQuery.ajax( {
				type : 'POST',
				contentType : 'application/json',
				url : 'userInfo/login.do',
				data : jsonLoginInfo,
				dataType : 'json',
				success : function(resp) {
					if (resp.successed) {
						$('#loginDialog').unbind( "dialogbeforeclose" );
						$('#loginDialog').bind( "dialogbeforeclose", function(event, ui) {
							return true;
						});
						$('#loginDialog').dialog('close');
					} else {
						alert(resp.errors[0].message);
					}
				},
				error : ajaxFailed
			});
		}

		function logout() {
			jQuery.ajax( {
				type : 'POST',
				contentType : 'application/json',
				url : 'userInfo/logout.do',
				dataType : 'json',
				success : function(resp) {
					if (resp.successed) {
						$('#loginDialog').unbind( "dialogbeforeclose" );
						$('#loginDialog').bind( "dialogbeforeclose", function(event, ui) {
							return false;
						});
						$('#loginDialog').dialog('open');
						init();
					} else {
						alert(resp.errors[0].message);
					}
				},
				error : ajaxFailed
			});
		}
		
		function ajaxFailed(XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest.responseText);
		};
		
		function load(page) {
			$('#main').load(page);
		}
		
		// Pushlet Event Callback from Server
	function onData(event) {
		var msg=event.get("message");
		if(msg){
			 $.omMessageTip.show({
            	title : '新闻',
            	content : msg
        	 });
		}
	}
	
	function init() {
		initDHTML();
		p_join_listen('/CometDemo/TestRate');
	}
	</script>
</head>

<body>

<div id="loginDialog" title="登录"> 
	<form id="loginForm">
		<table>
			<tr>
				<td><label for="account">账号</label></td>
				<td><input type="text" name="account" id="account" /></td>
			</tr>
			<tr>
				<td><label for="password">密码</label></td>
				<td><input type="password" name="password" id="password" value="" /></td>
			</tr>
		</table>
	</form> 
</div>
<div id="regDialog" title="注册"> 
	<form id="regForm">
		<table>
			<tr>
				<td><label for="account">账号</label></td>
				<td><input type="text" name="account" id="account" /></td>
			</tr>			
			<tr>
				<td><label for="password">密码</label></td>
				<td><input type="password" name="password" id="password" value="" /></td>
			</tr>
			<tr>
				<td><label for="repassword">确认密码</label></td>
				<td><input type="password" name="repassword" id="repassword" value="" /></td>
			</tr>
			<tr>
				<td><label for="name">姓名</label></td>
				<td><input type="text" name="name" id="name" /></td>
			</tr>
			<tr>
				<td><label for="sex">性别</label></td>
				<td><select id="sex" name="sex" >
						<option value=""></option>
						<option value="male">男</option>
						<option value="female">女</option>
					</select></td>
			</tr>
			<tr>
				<td><label for="native_place">籍贯</label></td>
				<td><input type="text" name="native_place" id="native_place" value="" /></td>
			</tr>
			<tr>
				<td><label for="email">邮箱</label></td>
				<td><input type="text" name="email" id="email" value="" /></td>
			</tr>
			<tr>
				<td><label for="tel">手机</label></td>
				<td><input type="text" name="tel" id="tel" value="" /></td>
			</tr>
		</table>
	</form> 
</div>
<div id="header" class="layout">header</div>

<div id="menu" class="layout">
	<div id="accordion">
		<h3><a href="#">数据录入</a></h3>
		<div>
			<a href="#" onclick="load('pages/customer/inputCustomerInfo.html');">信息录入</a><br />
<!--			<a href="#" onclick="load('pages/adv/inputAdvInfo.html');">广告订单录入</a><br />-->
<!--			<a href="#">印刷订单录入</a><br />-->
<!--			<a href="#">印刷订单录入</a><br />-->
<!--			<a href="#">印刷订单录入</a><br />-->
<!--			<a href="#">印刷订单录入</a><br />-->
<!--			<a href="#">印刷订单录入</a>-->
		</div>

		<h3><a href="#">数据修改</a></h3>
		<div>
<!--			<a href="#">顾客信息</a><br />-->
<!--			<a href="#">修改广告订单</a><br />-->
<!--			<a href="#">修改印刷订单</a><br />-->
		</div>

		<h3><a href="#">数据查询</a></h3>
		<div>
			<a href="#" onclick="load('pages/customer/searchCustomerInfo.html');">顾客信息</a><br />
			<a href="#" onclick="load('pages/user/searchUserInfo.html');">用户信息</a><br />
			<a href="#" onclick="load('pages/task/searchTaskInfo.html');">任务信息</a><br />
			<a href="#" onclick="load('list.jsp');">用户信息2</a><br />
<!--			<a href="#">查询印刷订单</a><br />-->
		</div>

		<h3><a href="#">系统</a></h3>
		<div>
			<a href="#" onclick="logout();">登出</a>
		</div>
	</div>
</div>

<div id="main" class="layout">main</div>

<div id="footer" class="layout">footer</div>
<script type="text/javascript">p_embed()</script>
</body>

</html>